# %% import
# pip install chromadb sentence_transformers
from langchain_community.document_loaders import PyPDFLoader
from langchain_openai.embeddings import OpenAIEmbeddings

# %% document loaders
loader = PyPDFLoader("")
pages = loader.load_and_split()

print(pages)
# %% Text embedding models
import os

# os.environ['OPENAI_API_KEY'] = ""
# os.environ['OPENAI_API_BASE'] = ""
from dotenv import load_dotenv

load_dotenv()

embeddings = OpenAIEmbeddings()

from langchain_community.vectorstores import FAISS

faiss_index = FAISS.from_documents(pages, embeddings)
docs = faiss_index.similarity_search("中国哲学开端?", k=2)
print(docs)
